//
//  ExcellentDetailVC.m
//  Courses
//
//  Created by YiXuePxh on 15/5/20.
//  Copyright (c) 2015年 boyibang. All rights reserved.
//

#import "ExcellentDetailVC.h"
#import "WTFRect.h"
#import "ExcellentPlay.h"
#import "ExcellentDetailCell.h"
@interface ExcellentDetailVC ()<UITableViewDelegate,UITableViewDataSource>
{
    CGFloat _ratio;
}
@end

@implementation ExcellentDetailVC
-(instancetype)initWithJsonDict:(id)jsonDict ClassName:(NSString* )className{
    if (self = [super init]) {
        self.className = className;
        self.detailList = [[NSMutableArray alloc]init];
        for (id json in jsonDict) {
            DetaileCourse* course = [[DetaileCourse alloc]initWithJsonDict:json];
            [_detailList addObject:course];
        }
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _ratio = [UIScreen mainScreen].bounds.size.width / 320.0;
    [self.tabBarController.tabBar setHidden:YES];
    CGSize screenSize = [UIScreen mainScreen].bounds.size;
    UITableView* table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, screenSize.height)];
    table.tableFooterView = [[UIView alloc]init];
    [self.view addSubview:table];
    table.delegate = self;
    table.dataSource = self;
    self.title = _className;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _detailList.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return AutoFloat(68);
}
-(UITableViewCell* )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString* CellIdentifier = [NSString stringWithFormat:@"cell%ld",(long)indexPath.row];
    ExcellentDetailCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[ExcellentDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    cell.cellTextLabel.text = [NSString stringWithFormat:@"%@",[_detailList[indexPath.row] courseName]];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([PXHGetNetworkStatus isWifi]) {
        NSLog(@"index:%ld",(long)indexPath.row);
        ExcellentPlay* playVC = [[ExcellentPlay alloc]initWithType:LTCplayerTypeNormal];
        DetaileCourse* course = _detailList[indexPath.row];
        playVC.coutrse = course;
        [playVC getVodInPutMessage:@"a821022973" VideoId:course.videoId ap:YES];
        [self.navigationController presentViewController:playVC animated:NO completion:nil];//会跳转到一个全新的界面 移除navi和tabbar
    }else{
        [self showMBHUDByMssage:@"请在WiFi环境下观看视频" Time:1];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
